<template>
	<view class="smslogin-index">
		<view>
			<view class="smslogin-index-title">
				<view class="smslogin-index-title-sms">选择你感兴趣的圈子</view>
				<view class="smslogin-index-title-huanying">选择好圈子更快乐</view>
			</view>
		</view>
		<view class="conent">
			<view class="conent_item" v-for="(item, index) in list" :key="index" @click="conentCLick(item.label)">
				<view class="mengcneg" v-if="inexList.indexOf(item.label) == -1"></view>
				<image class="image" :src="item.img" alt=""></image>
				<view class="title">{{ item.label }}</view>
			</view>
		</view>
		<view class="button" @click="goTo">我已选好啦</view>
	</view>
</template>

<script>
	import {
		editCircleCategory
	} from '@/api/index.js'
	export default {
		data() {
			return {
				list: [{
						label: '自然科学',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940369644.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '天文知识',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940363860.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '航天科技',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940347415.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '信息通信',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940367837.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '人工智能',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940351575.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '生物工程',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940361208.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '神奇化学',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940354233.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '物理探秘',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940365902.jpg?x-oss-process=image/resize,w_300'
					},
					{
						label: '生命健康',
						img: 'https://dujiaojing.oss-cn-huhehaote.aliyuncs.com/uploads/2025/7/31/1753940358938.jpg?x-oss-process=image/resize,w_300'
					},
				],
				inexList: []
			}
		},
		onShow() {

		},
		onLoad() {},
		methods: {
			async goTo() {
				await editCircleCategory({
					circleCategory: this.inexList.join(',')
				})
				uni.switchTab({
					url: "/pages/tabbar/home/home"
				})
			},
			conentCLick(index) {
				if (this.inexList.indexOf(index) == -1) {
					this.inexList.push(index)
				} else {
					this.inexList.splice(this.inexList.indexOf(index), 1)
				}
			}
		},
		onReady() {}
	}
</script>

<style lang="less" scoped>
	.smslogin-index {
		display: flex;
		flex-flow: column;
		padding-bottom: 30px;
		box-sizing: border-box;
		width: 100%;
		height: 100vh;

		.smslogin-index-title {
			.smslogin-index-title-sms {
				margin: 120rpx 0 30rpx 50rpx;
				color: #1A1B1C;
				font-size: 42rpx;
				font-weight: Semibold;
			}

			.smslogin-index-title-huanying {
				margin: 0 0 102rpx 50rpx;
				color: #C0C6D0;
				font-size: 28rpx;
				font-weight: Regular;
			}
		}

		.conent {
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			width: 100%;
			margin-top: 40rpx;
			box-sizing: border-box;
			padding: 0 30rpx;

			.conent_item {
				width: 180rpx;
				display: flex;
				flex-wrap: wrap;
				justify-content: center;
				margin-bottom: 25rpx;
				position: relative;

				.mengcneg {
					width: 180rpx;
					height: 147rpx;
					background-color: rgba(198, 198, 198, 0.5);
					position: absolute;
					top: 0;
					left: 0;
					border-radius: 20rpx;
				}

				.image {
					width: 180rpx;
					height: 147rpx;
					border-radius: 20rpx;
				}

				.title {
					color: #1A1B1C;
					font-size: 30rpx;
					font-weight: 500;
					margin-top: 10rpx;
				}
			}
		}

		.button {
			width: 300rpx;
			height: 60rpx;
			background-color: rgb(34, 175, 229);
			text-align: center;
			line-height: 60rpx;
			font-size: 30rpx;
			color: #fff;
			border-radius: 30rpx;
			margin: auto;
			margin-top: 40rpx;
		}
	}
</style>